/*
 * QuickSort.java
 *
 */
package da522A_lab4B_2011;

/**
 *
 * @author lol
 */
public class QuickSort {

    /** Creates a new instance of QuickSort */
    public QuickSort() {
    }

    public void QuickSort(int[] a, int start, int end) {
        if (start < end) {
            int x = start;
            int y = end;
            int input = a[x];
            while (x != y) {
                while (x < y && input < a[y]) {
                    y--;
                }
                if (x < y) {
                    a[x++] = a[y];
                }
                while (x < y && input > a[x]) {
                    x++;
                }
                if (x < y) {
                    a[y--] = a[x];
                }

            }
            a[x] = input;
            QuickSort(a, start, y - 1);
            QuickSort(a, x + 1, end);
        }
    }
}
